package com.pcy.project;


import com.pcy.project.address.Address;
import com.pcy.project.rpc.GetBestBlockHash;
import com.pcy.project.rpc.HotVideoService;

import java.security.KeyPair;
import java.util.Scanner;

/**
 * @author 清秋
 * @date 13:07 2021/12/7
 * @Description
 */
public class Main {
    public static void main(String[] args) {
        System.out.println( "Hello World!" );
        Main test = new Main();
        test.run();
    }

    public void run() {
        System.out.println( "======Java期末大作业功能系统======" );
        System.out.println( "本系统实现了以下功能：" );
        System.out.println( "1，热门视频 2.比特币客户端通信 3.比特币地址生成 0.退出" );
        while (true) {
            menu();
        }
    }

    public void menu() {
        System.out.println( "请输入你的选择：" );
        Scanner scanner = new Scanner( System.in );
        String user_input = scanner.next();
        int num = Integer.parseInt( user_input );
        switch (num) {
            case 1:
                HotVideoService service = new HotVideoService();
                service.getHotVideo();
                break;

            case 2:
                GetBestBlockHash xxx = new GetBestBlockHash();
                String bestBlockHash = xxx.getBestBlockHash();
                System.out.println( "获取当前最新区块hash值:"+bestBlockHash );
                break;
            case 3:
                Address address = new Address();
                KeyPair keyPair = address.generateKey();
                String adrStr = address.newAddress( keyPair );
                System.out.println( "新地址是：" + adrStr );
                break;
            case 0:
                System.exit( 0 );
                break;
            default:
                System.out.println( "输入有误，不支持该功能，请重试。" );
        }
    }
}